package com.cqupt.one_to_many;

import com.cqupt.newbean.Classes;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;

public class Test{
    @org.junit.Test
    public void SelectClass()throws Exception{
        InputStream is = Resources.getResourceAsStream("MyBatisConfig.xml");
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(is);
        SqlSession sqlSession = build.openSession(true);
        ClassesMapper mapper = sqlSession.getMapper(ClassesMapper.class);
        List<Classes> classes = mapper.selectClasses();
        for(Classes c : classes){
            System.out.println(c);
        }
    }
}
